package com.pureman.androidapp2;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.etsy.android.sample.AndroidStaggeredGridActivity;
import com.example.listviewfilter.ListviewFilterActivity;
import com.example.zxingdemo.ZXingDemoActivity;
import com.github.florent37.materialviewpager.sample.MaterialviewpagerActivity;
import com.haarman.listviewanimations.ListViewAnimationsActivity;
import com.jaredrummler.materialspinner.example.MaterialSpinnerActivity;
import com.jpardogo.android.flabbylistview.FlabbyListViewActivity;
import com.ogaclejapan.smarttablayout.demo.SmartTabLayoutActivity;
import com.pureman.androidapp2.zxing.ZXingActivity;
import com.yalantis.contextmenu.ContextMenuActivity;

import org.adw.samples.discreteseekbar.DiscreteSeekBarActivity;

import me.gujun.android.taggroup.demo.AndroidTagGroupActivity;
import me.imid.swipebacklayout.demo.SwipebacklayoutActivity;
import za.co.immedia.pinnedheaderlistviewexample.PinnedHeaderListViewActivity;

public class ListActivity extends AppCompatActivity {

    private ListView listView;
    private String[] explains;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);

        initView();
        setData();
    }

    private void initView() {
        listView = (ListView) findViewById(R.id.listView);
        //注册监听事件
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView parent, View view,
                                    int position, long id) {
                String string = (String) parent.getItemAtPosition(position);
                switch (position) {
                    case 0:
                        startActivity(new Intent(ListActivity.this, MaterialviewpagerActivity.class));
                        break;
                    case 1:
                        startActivity(new Intent(ListActivity.this, ListViewAnimationsActivity.class));
                        break;
                    case 2:
                        startActivity(new Intent(ListActivity.this, SwipebacklayoutActivity.class));
                        break;
                    case 3:
                        startActivity(new Intent(ListActivity.this, SmartTabLayoutActivity.class));
                        break;
                    case 4:
                        startActivity(new Intent(ListActivity.this, ZXingActivity.class));
                        break;
                    case 5:
                        startActivity(new Intent(ListActivity.this, ZXingDemoActivity.class));
                        break;
                    case 6:
                        startActivity(new Intent(ListActivity.this, FlabbyListViewActivity.class));
                        break;
                    case 7:
                        startActivity(new Intent(ListActivity.this, PinnedHeaderListViewActivity.class));
                        break;
                    case 8:
                        startActivity(new Intent(ListActivity.this, ListviewFilterActivity.class));
                        break;
                    case 9:
                        startActivity(new Intent(ListActivity.this, AndroidStaggeredGridActivity.class));
                        break;
                    case 10:
                        startActivity(new Intent(ListActivity.this, DiscreteSeekBarActivity.class));
                        break;
                    case 11:
                        startActivity(new Intent(ListActivity.this, ContextMenuActivity.class));
                        break;
                    case 12:
                        startActivity(new Intent(ListActivity.this, AndroidTagGroupActivity.class));
                        break;
                    case 13:
                        startActivity(new Intent(ListActivity.this, MaterialSpinnerActivity.class));
                        break;
                }
                Toast.makeText(ListActivity.this, explains[position], Toast.LENGTH_SHORT).show();
            }
        });
    }

    private void setData() {
        explains = getResources().getStringArray(R.array.explains);
        ArrayAdapter arrayAdapter = new ArrayAdapter(
                this, android.R.layout.simple_list_item_1,
                explains);
        listView.setAdapter(arrayAdapter);
    }
}
